﻿#include "ReturnEventFilter.h"
#include<QEvent>

ReturnEventFilter::ReturnEventFilter(std::function<bool(QKeyEvent*)> fun, QObject* parent)
    :EventFilter([=](QEvent* ev)->bool {
    QKeyEvent* ke = static_cast<QKeyEvent*>(ev);
    if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return)
    {
        return m_fun(ke);        //该事件已经被处理
    }
    return false;
        }, QEvent::KeyPress,parent),
	m_fun(fun)
{
}